function getContent() {
global $wgRequest, $wgUser, $wgOut;
- # Get variables from query string :P
- $action = $wgRequest->getText( 'action', 'view' );
- $section = $wgRequest->getText( 'section' );
- $preload = $wgRequest->getText( 'preload' );
-
wfProfileIn( __METHOD__ );
if ( 0 == $this->getID() ) {
- if ( 'edit' == $action ) {
- wfProfileOut( __METHOD__ );
-
- # If requested, preload some text.
- $text=$this->getPreloadedText($preload);
-
- # We used to put MediaWiki:Newarticletext here if
- # $text was empty at this point.
- # This is now shown above the edit box instead.
- return $text;
- }
wfProfileOut( __METHOD__ );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
return "<div class='noarticletext'>$ret</div>";
} else {
$this->loadContent();
- if($action=='edit') {
- if($section!='') {
- if($section=='new') {
- wfProfileOut( __METHOD__ );
- $text=$this->getPreloadedText($preload);
- return $text;
- }
-
- # strip NOWIKI etc. to avoid confusion (true-parameter causes HTML
- # comments to be stripped as well)
- $rv=$this->getSection($this->mContent,$section);
- wfProfileOut( __METHOD__ );
- return $rv;
- }
- }
wfProfileOut( __METHOD__ );
return $this->mContent;
}
}
- /**
- * Get the contents of a page from its title and remove includeonly tags
- *
- * @param $preload String: the title of the page.
- * @return string The contents of the page.
- */
- function getPreloadedText($preload) {
- if ( $preload === '' )
- return '';
- else {
- $preloadTitle = Title::newFromText( $preload );
- if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) {
- $rev=Revision::newFromTitle($preloadTitle);
- if ( is_object( $rev ) ) {
- $text = $rev->getText();
- // TODO FIXME: AAAAAAAAAAA, this shouldn't be implementing
- // its own mini-parser! -ævar
- $text = preg_replace( '~</?includeonly>~', '', $text );
- return $text;
- } else
- return '';
- }
- }
- }
-
/**
* This function returns the text of a section, specified by a number ($section).
* A section is text under a heading like == Heading == or \<h1\>Heading\</h1\>, or
* @param $text String: text to look in
* @param $section Integer: section number
* @return string text of the requested section
+ * @deprecated
*/
function getSection($text,$section) {
global $wgParser;
# unused:
# $lastid = $oldid;
}
+
if ( !$oldid ) {
$oldid = 0;
}
return;
}
}
+
# Should the parser cache be used?
$pcache = $wgEnableParserCache &&
intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
global $wgTitle;
$this->mTitle =& $wgTitle;
}
+
+ /**
+ * Fetch initial editing page content.
+ */
+ private function getContent() {
+ global $wgRequest, $wgParser;
+
+ # Get variables from query string :P
+ $section = $wgRequest->getVal( 'section' );
+ $preload = $wgRequest->getVal( 'preload' );
+
+ wfProfileIn( __METHOD__ );
+
+ $text = '';
+ if( !$this->mTitle->exists() ) {
+
+ # If requested, preload some text.
+ $text = $this->getPreloadedText( $preload );
+
+ # We used to put MediaWiki:Newarticletext here if
+ # $text was empty at this point.
+ # This is now shown above the edit box instead.
+ } else {
+ // FIXME: may be better to use Revision class directly
+ // But don't mess with it just yet. Article knows how to
+ // fetch the page record from the high-priority server,
+ // which is needed to guarantee we don't pick up lagged
+ // information.
+
+ $text = $this->mArticle->getContent();
+
+ if( $section != '' ) {
+ if( $section == 'new' ) {
+ $text = $this->getPreloadedText( $preload );
+ } else {
+ $text = $wgParser->getSection( $text, $section );
+ }
+ }
+ }
+
+ wfProfileOut( __METHOD__ );
+ return $text;
+ }
+
+ /**
+ * Get the contents of a page from its title and remove includeonly tags
+ *
+ * @param $preload String: the title of the page.
+ * @return string The contents of the page.
+ */
+ private function getPreloadedText($preload) {
+ if ( $preload === '' )
+ return '';
+ else {
+ $preloadTitle = Title::newFromText( $preload );
+ if ( isset( $preloadTitle ) && $preloadTitle->userCanRead() ) {
+ $rev=Revision::newFromTitle($preloadTitle);
+ if ( is_object( $rev ) ) {
+ $text = $rev->getText();
+ // TODO FIXME: AAAAAAAAAAA, this shouldn't be implementing
+ // its own mini-parser! -ævar
+ $text = preg_replace( '~</?includeonly>~', '', $text );
+ return $text;
+ } else
+ return '';
+ }
+ }
+ }
/**
* This is the function that extracts metadata from the article body on the first view.
if ( !$wgUseMetadataEdit ) return ;
if ( $wgMetadataWhitelist == '' ) return ;
$s = '' ;
- $t = $this->mArticle->getContent();
+ $t = $this->getContent();
# MISSING : <nowiki> filtering
if ( ! $this->mTitle->userCanEdit() ) {
wfDebug( "$fname: user can't edit\n" );
- $wgOut->readOnlyPage( $this->mArticle->getContent(), true );
+ $wgOut->readOnlyPage( $this->getContent(), true );
wfProfileOut( $fname );
return;
}
return;
} else {
wfDebug( "$fname: read-only page\n" );
- $wgOut->readOnlyPage( $this->mArticle->getContent(), true );
+ $wgOut->readOnlyPage( $this->getContent(), true );
wfProfileOut( $fname );
return;
}
} else if ( $this->diff ) {
$this->formtype = 'diff';
} else {
- $wgOut->readOnlyPage( $this->mArticle->getContent() );
+ $wgOut->readOnlyPage( $this->getContent() );
wfProfileOut( $fname );
return;
}
*/
function initialiseForm() {
$this->edittime = $this->mArticle->getTimestamp();
- $this->textbox1 = $this->mArticle->getContent();
+ $this->textbox1 = $this->getContent();
$this->summary = '';
if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI )
$this->textbox1 = wfMsgWeirdKey( $this->mArticle->mTitle->getText() ) ;
$wgOut->addWikiText( wfMsg( 'explainconflict' ) );
$this->textbox2 = $this->textbox1;
- $this->textbox1 = $this->mArticle->getContent();
+ $this->textbox1 = $this->getContent();
$this->edittime = $this->mArticle->getTimestamp();
} else {
} else {
# if user want to see preview when he edit an article
if( $wgUser->getOption('previewonfirst') and ($this->textbox1 == '')) {
- $this->textbox1 = $this->mArticle->getContent();
+ $this->textbox1 = $this->getContent();
}
$toparse = $this->textbox1;
# If the user made changes, preserve them when showing the markup
# (This happens when a user is blocked during edit, for instance)
$first = $this->firsttime || ( !$this->save && $this->textbox1 == '' );
- $source = $first ? $this->mArticle->getContent() : $this->textbox1;
+ $source = $first ? $this->getContent() : $this->textbox1;
# Spit out the source or the user's modified version
$rows = $wgUser->getOption( 'rows' );